<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath}/script/swfupload/swfupload.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/swfupload/handlers.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery.form.js"></script>
<script type="text/javascript">

	$(document).ready(function(){
		upload();
	});
	//上传照片
	function upload(){
		swfu = new SWFUpload({
			upload_url: "${pageContext.request.contextPath}/admin/uploadFile/uploadFile.do?m=upload",
			post_params: {},
			file_size_limit : "3MB",	// 1000MB
			file_types : "*.jpg;*.png;*.jpeg;*.bmp;*.gif;",
			file_post_name: "file",
			file_types_description : "所有文件",
			file_upload_limit : "0",
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,//选择好文件后提交
			file_queued_handler : fileQueued1,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess1,
			upload_complete_handler : uploadComplete,
			button_placeholder_id : "spanButtonPlaceholder",
			button_width: 200,
			button_height: 30,
			button_text : '<span class="buttonStyle">+添加照片</span>',
			button_text_style:'.buttonStyle{font-size:25px;color:#de2183;font-family:"黑体";}',
			button_text_top_padding: 0,
			button_text_left_padding: 10,
			button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
			button_cursor: SWFUpload.CURSOR.HAND,
			flash_url : "${pageContext.request.contextPath}/script/swfupload/swfupload.swf",
			custom_settings : {
				upload_target : "divFileProgressContainer"
			},
			debug: false  //是否显示调试窗口
		});/*
		var settings = {
				flash_url : "${pageContext.request.contextPath}/script/swfupload/swfupload.swf",
				upload_url: "${pageContext.request.contextPath}/admin/uploadFile/uploadFile.do?m=upload",
				post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
				file_size_limit : "100 MB",
				file_types : "*.*",
				file_types_description : "All Files",
				file_upload_limit : 100,
				file_queue_limit : 0,
				custom_settings : {
					progressTarget : "divFileProgressContainer",
					cancelButtonId : "btnCancel"
				},
				debug: false,
				// Button settings
//				button_image_url: "images/TestImageNoText_65x29.png",
				button_placeholder_id : "spanButtonPlaceholder",
				button_width: 200,
				button_height: 30,
				button_text : '<span class="buttonStyle">+添加照片</span>',
				button_text_style:'.buttonStyle{font-size:25px;color:#de2183;font-family:"黑体";}',
				button_text_top_padding: 0,
				button_text_left_padding: 10,
				button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				button_cursor: SWFUpload.CURSOR.HAND,
				// The event handler functions are defined in handlers.js
				file_queued_handler : fileQueued1,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
//				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess1,
				upload_complete_handler : uploadComplete //,
//				queue_complete_handler : queueComplete	// Queue plugin event
			};

			swfu = new SWFUpload(settings);
		*/
	}	

	function fileQueued1(file){
		alert(1);
	}
	
	function uploadSuccess1(file,result){
		alert(result);
	}
	
	//上传完成
	function uploadComplete(file) {
		try {
			if (this.getStats().files_queued > 0) {
				this.startUpload();
			} else {
				var progress = new FileProgress(file,  this.customSettings.upload_target);
				progress.setComplete();
			}
		} catch (ex) {
			this.debug(ex);
		}
	}
</script>
<title>上传打折信息</title>
</head>
<body>
	<form id="form1" action="index.php" method="post" enctype="multipart/form-data">
		<span id="spanButtonPlaceholder" ></span>
		<div id="divFileProgressContainer"></div>
	</form>
</body>
</html>